/**
 * Created by ZY on 2018/02/13
 */
let _ = require('lodash'),
  util = require('../helper/util'),
  errCode = require('../../conf/errorCode'),
  logger = require('../helper/logger'),
  service = require('../services/bannerService');

var tagLogger = new logger.TagLogger('DATA_CONTROLLER');

exports.addData = function(req, res, next) {
  service.addData(req.body, util.getHandle(req, res, errCode.ADD_DATA));
};

exports.getOperateByPage = function(req, res, next) {
  let {page, size, type,flag} = req.query;
  service.getOperateByPage(
    type,
    flag,
    page,
    size,
    util.getHandle(req, res, errCode.GET_DATA_BY_PAGE),
  );
};

exports.deleteOperateByIds = function(req, res, next) {
  let ids = req.params.operateId,
    {type} = req.body;

  service.deleteOperateByIds(
    type,
    ids,
    util.getHandle(req, res, errCode.DELETE_DATA_BY_IDS),
  );
};

//更新数据
exports.updateData = function(req, res, next) {
  let id = req.params.operateId,
    {type} = req.body;
  service.updateData(type,id, req.body, util.getHandle(req, res, errCode.UPDATE_DATA));
};

//更改位置
exports.moveOperatePosition = function(req, res, next) {
  let {type,operateId,moveType} = req.body;
  service.moveOperatePosition(type,operateId,moveType, util.getHandle(req, res, errCode.UPDATE_DATA));
};
